#include <fcntl.h>
#include <stdio.h>
#include <string.h>
#include <sys/select.h>

#define DATA_NUM	(10)
#define MEM_CLEAR	(0x100)

int main(int argc, char *argv[])
{
	int fd;
	int WD, RD;
	char buf[DATA_NUM] = "111111";
	
	fd = open("/dev/globalmem", O_RDWR);
	printf("fd : %d\n", fd);

	if(fd == -1)
		perror("open file failed\n");
	else
		printf("open file success\n");


	WD = write(fd, buf, DATA_NUM);
	//ioctl(fd, MEM_CLEAR);
	lseek(fd, SEEK_SET, 0);
	RD = read(fd, buf, DATA_NUM);
	printf("WD : %d\nRD : %d\n", WD, RD);
	printf("%s\n", buf);
	RD = read(fd, buf, DATA_NUM);
	printf("WD : %d\nRD : %d\n", WD, RD);
	printf("%s\n", buf);

	return 0;
}
